import org.apache.shiro.crypto.hash.Sha1Hash

class BootStrap {

     def init = { servletContext ->
       def criteria = ShiroUser.createCriteria()
       def result = criteria{
    	   and {
    		   eq("username", "admin")
    	   }
       }
       if (result.size() == 0) {
    	   def user = new ShiroUser(username: "admin", passwordHash: new Sha1Hash("admin").toHex())
    	   user.addToPermissions("*:*")
    	   user.save()
           System.out.println("admin user saved.")
       }
       System.out.println("finish init")
     }
     def destroy = {
     }
} 